
/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MbRolesManager
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using MP.Core.Library;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MbRolesManager : MbRolesManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public MbRolesManager()
		{
			// Nothing for now.
		}
		
		/// <summary>
		/// Method to create an instance of MbRolesManager
		/// </summary>
		/// <returns>An instant of MbRolesManager class</returns>
		public static MbRolesManager CreateInstant()
		{
			return new MbRolesManager();
		}

        public DataSet GetRoleByDepartId(Guid DepartId)
        {
            string strSQL = "PRC_GetRoleByDepart";
            SqlParameter param = new SqlParameter("@DepartId", DepartId);
            return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringOBS, CommandType.StoredProcedure, strSQL, param);
        }

        public DataSet GetRolesInUserByDepart(string userName)
        {
            string strSQL = "PRC_GetRolesInUser";
            SqlParameter param = new SqlParameter("@UserName", userName);
            return SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringOBS, CommandType.StoredProcedure, strSQL, param);
        }

        public bool CheckDeleteRole(Guid roleId)
        {
            string strSQL = "PRC_CheckDeleteRole";
            SqlParameter[] param = new SqlParameter[1];
            param[0] = new SqlParameter("@RoleId", roleId);
            object k = SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringOBS, CommandType.StoredProcedure, strSQL, param);
            if (k != null)
                return (bool)k;
            return false;
        }
        public DataTable CountRole()
        {
            string strSQL = "mb_countRole";
            return SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringOBS, CommandType.StoredProcedure, strSQL);
        }
        public DataTable GetListRoleDetailByRoleID(Guid RoleID)
        {
            string strSQL = "GetListRoleByRoleID";
            SqlParameter[] param=new SqlParameter[1];
            param[0] = new SqlParameter("@RoleID", RoleID);
            return SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringOBS, CommandType.StoredProcedure, strSQL, param);

        }
	}
}
